#include <stdio.h>
#include <stdlib.h>
#include "pe12-2a.h"

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int mode; //存储模式用的, 0为metric, 1 为US

int main(int argc, char *argv[])
{
	int scanned;

	printf("Enter 0 for metric mode , 1 for US mode!\n");
	scanned = scanf("%d", &mode); //输入格式判断,函数中还有一层判断
	while (mode == -1 || mode == 0 || mode == 1)
	{
		if (scanned != 1)
		{
			printf("Imput invalid , Pls re Enter a num");
			while (getchar() != '\n') //refresh buffer
			{
				continue;
				puts(mode);
			}
			continue;
		}
		if (mode > 0)
		{
			set_mode(mode);
			get_info();
			show_info();
		}

		printf("Enter 0 for metric mode , 1 for US mode!\n");
		printf(" (-1) to QUIT!\n");
		scanned = scanf("%d", &mode);
	}
	printf("Done!\n");
	system("pause");

	return 0;
}